package com.cl.gateway.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.Set;

/**
 * 放行资源配置
 */
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "auth.permit")
public class PermitProperties {

//    public PermitProperties() {
//        this.antPathMatcher = new AntPathMatcher();
//    }
//
//    private AntPathMatcher antPathMatcher;

    /**
     * 需要放行的资源路径列表
     */
    private Set<String> resource;

    public Set<String> getResource() {
        return resource;
    }

    public void setResource(Set<String> resource) {
        this.resource = resource;
    }

    /**
     * 校验是否属于需要放心的资源
     * @param requestPath 请求路径
     */
    public boolean permit(String requestPath) {
//        return this.resource.stream()
//                .anyMatch(r -> antPathMatcher.match(r, requestPath));
        return true;
    }
}
